package com.ruoyi.analytics.domain;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import java.io.Serializable;
import java.util.Map;

// @Document注解指定了这对应MongoDB中的哪个集合
@Document(collection = "analytics_events")
public class AnalyticsEvent implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id // 标记为主键
    private String id; // MongoDB 自动生成的 _id

    @Field("event_id") // 映射字段名
    private String eventId;

    @Field("event_name")
    private String eventName;

    @Field("event_time")
    private String eventTime;

    @Field("event_type")
    private String eventType;

    private User user;
    private Device device;
    private Page page;
    private Properties properties;
    private Location location;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getEventId() {
        return eventId;
    }

    public void setEventId(String eventId) {
        this.eventId = eventId;
    }

    public String getEventName() {
        return eventName;
    }

    public void setEventName(String eventName) {
        this.eventName = eventName;
    }

    public String getEventTime() {
        return eventTime;
    }

    public void setEventTime(String eventTime) {
        this.eventTime = eventTime;
    }

    public String getEventType() {
        return eventType;
    }

    public void setEventType(String eventType) {
        this.eventType = eventType;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Device getDevice() {
        return device;
    }

    public void setDevice(Device device) {
        this.device = device;
    }

    public Page getPage() {
        return page;
    }

    public void setPage(Page page) {
        this.page = page;
    }

    public Properties getProperties() {
        return properties;
    }

    public void setProperties(Properties properties) {
        this.properties = properties;
    }

    public Location getLocation() {
        return location;
    }

    public void setLocation(Location location) {
        this.location = location;
    }

    public Map<String, Object> getExtraData() {
        return extraData;
    }

    public void setExtraData(Map<String, Object> extraData) {
        this.extraData = extraData;
    }

    // 为了兼容未来可能增加的任意字段，可以加一个Map
    private Map<String, Object> extraData;


    // Getter and Setter ...

    // --- 内部静态类 ---

    public static class User {
        @Field("user_id")
        private String userId;
        @Field("session_id")
        private String sessionId;
        @Field("device_id")
        private String deviceId;
        @Field("is_new_user")
        private Boolean isNewUser;
        // Getter and Setter ...

        public String getUserId() {
            return userId;
        }

        public void setUserId(String userId) {
            this.userId = userId;
        }

        public String getSessionId() {
            return sessionId;
        }

        public void setSessionId(String sessionId) {
            this.sessionId = sessionId;
        }

        public String getDeviceId() {
            return deviceId;
        }

        public void setDeviceId(String deviceId) {
            this.deviceId = deviceId;
        }

        public Boolean getNewUser() {
            return isNewUser;
        }

        public void setNewUser(Boolean newUser) {
            isNewUser = newUser;
        }
    }

    public static class Device {
        private String os;
        @Field("device_model")
        private String deviceModel;
        @Field("screen_resolution")
        private String screenResolution;
        @Field("network_type")
        private String networkType;
        @Field("app_version")
        private String appVersion;
        // Getter and Setter ...

        public String getOs() {
            return os;
        }

        public void setOs(String os) {
            this.os = os;
        }

        public String getDeviceModel() {
            return deviceModel;
        }

        public void setDeviceModel(String deviceModel) {
            this.deviceModel = deviceModel;
        }

        public String getScreenResolution() {
            return screenResolution;
        }

        public void setScreenResolution(String screenResolution) {
            this.screenResolution = screenResolution;
        }

        public String getNetworkType() {
            return networkType;
        }

        public void setNetworkType(String networkType) {
            this.networkType = networkType;
        }

        public String getAppVersion() {
            return appVersion;
        }

        public void setAppVersion(String appVersion) {
            this.appVersion = appVersion;
        }
    }

    public static class Page {
        @Field("page_url")
        private String pageUrl;
        @Field("page_title")
        private String pageTitle;
        private String referrer;
        @Field("element_id")
        private String elementId;
        // Getter and Setter ...

        public String getPageUrl() {
            return pageUrl;
        }

        public void setPageUrl(String pageUrl) {
            this.pageUrl = pageUrl;
        }

        public String getPageTitle() {
            return pageTitle;
        }

        public void setPageTitle(String pageTitle) {
            this.pageTitle = pageTitle;
        }

        public String getReferrer() {
            return referrer;
        }

        public void setReferrer(String referrer) {
            this.referrer = referrer;
        }

        public String getElementId() {
            return elementId;
        }

        public void setElementId(String elementId) {
            this.elementId = elementId;
        }
    }

    public static class Properties {
        @Field("product_id")
        private String productId;
        private String category;
        private Double price;
        private Integer quantity;
        @Field("scroll_depth")
        private Integer scrollDepth;
        // Getter and Setter ...

        public String getProductId() {
            return productId;
        }

        public void setProductId(String productId) {
            this.productId = productId;
        }

        public String getCategory() {
            return category;
        }

        public void setCategory(String category) {
            this.category = category;
        }

        public Double getPrice() {
            return price;
        }

        public void setPrice(Double price) {
            this.price = price;
        }

        public Integer getQuantity() {
            return quantity;
        }

        public void setQuantity(Integer quantity) {
            this.quantity = quantity;
        }

        public Integer getScrollDepth() {
            return scrollDepth;
        }

        public void setScrollDepth(Integer scrollDepth) {
            this.scrollDepth = scrollDepth;
        }
    }

    public static class Location {
        private String country;
        private String region;
        private String city;
        // Getter and Setter ...


        public String getCountry() {
            return country;
        }

        public void setCountry(String country) {
            this.country = country;
        }

        public String getRegion() {
            return region;
        }

        public void setRegion(String region) {
            this.region = region;
        }

        public String getCity() {
            return city;
        }

        public void setCity(String city) {
            this.city = city;
        }
    }
}